<template>
    <view :style="objColor">
        <!-- mine/pages/collectionList/collectionList.wxml -->
        <!-- 站点信息 -->
        <view v-if="siteItemData.list.length > 0">
            <siteListItem id="tip" :itemData="siteItemData" @myevent="myevent($event, { tagId: 'tip' })"></siteListItem>
            <view class="noList" v-if="LoadingComplete">全部加载完成</view>
        </view>
        <view v-if="siteItemData.list.length == 0&&loading">
            <Upgrading text="暂无收藏"></Upgrading>
        </view>
    </view>
</template>

<script>
	'use strict';
	import siteListItem from '../../../components/site-list/site-list-item';
	import Upgrading from '../../../components/upgrading/upgrading';

	// exports.__esModule = true; // mine/pages/collectionList/collectionList.ts

	import { indexStationNewV2, } from '@/api/mobileUpdate';

	var app = getApp();
	var https_1 = require('./../../../api/https.js');
	export default {
		components: {
			siteListItem,
			Upgrading
		},
		data() {
			return {
				loading:false,
				//站点组件
				siteItemData: {
					list: []
				},
				LoadingComplete: false,
				params: {
					current: 1,
					pageSize: 10,
					pages: 1
				}
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function () {},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function () {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function () {
			this.getMyCollectList('replace');
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function () {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function () {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function () {},
		//  * 页面上拉触底事件的处理函数
		onReachBottom: function () {
			var that = this;
			var current = that.params.current + 1;

			if (that.params.current < that.params.pages) {
				that.params.current=current
				this.getMyCollectList('');
			}
		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function () {},
		methods: {
			//站点收藏列表
			getMyCollectList: function (type) {
				var that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				that.loading=false
				var params = this.params;
				// https_1
				// 	// .getMyCollectList({
				// 	// 	current: params.current,
				// 	// 	pageSize: params.pageSize,
				// 	// 	latitude: uni.getStorageSync('latitude') ? uni.getStorageSync('latitude') : '23.135618',
				// 	// 	longitude: uni.getStorageSync('longitude') ? uni.getStorageSync('longitude') : '113.270766'
				// 	// })
				// 	.indexStationNew({
				// 		areaId: uni.getStorageSync('cityId'),
				// 		areaName: uni.getStorageSync('cityName') || uni.getStorageSync('currentCityName'),
				// 		latitude: uni.getStorageSync('latitude'),
				// 		longitude: uni.getStorageSync('longitude'),
				// 		sellerNo: app.globalData.sellerNo,
				// 		type: -1,
				// 		current: params.current,
				// 		pageSize: params.pageSize,
				// 		isCollect: true,
				// 		searchType: 1
				// 	})

					// 获取站点列表v2
					let siteFiltering = uni.getStorageSync('siteFiltering');
					let siteLabelSelection = uni.getStorageSync('siteLabelSelection');
					let tagFilter = {
						...siteFiltering,
						...siteLabelSelection
					}
					if(siteFiltering.gunType && siteLabelSelection.gunType){
						tagFilter.gunType = [...siteFiltering.gunType, ...siteLabelSelection.gunType]
					}
					if(siteFiltering.serviceFacilities && siteLabelSelection.serviceFacilities){
						tagFilter.serviceFacilities = [...siteFiltering.serviceFacilities, ...siteLabelSelection.serviceFacilities]
					}
					console.log(tagFilter,'collectionList==>>tagFilter.....')
					let datas = {
						"sellerId": getApp().globalData.sellerId,
						"areaId": uni.getStorageSync('cityId') || app.globalData.defaultCity.cityId,
						"latitude": uni.getStorageSync('latitude')  || app.globalData.defaultCity.latitude,
						"longitude": uni.getStorageSync('longitude') || app.globalData.defaultCity.longitude,
						"current": params.current,
						"pageSize": params.pageSize,
						"sortMode": 3,
						"isCollect": true,
						...tagFilter,
					}
					console.log(datas,'index站点筛选条件.....');

					indexStationNewV2({...datas})
					.then(function (res) {
						if (res.code == 0) {
							that.params.current=res.data.pageNo,
								that.params.pages=res.data.pages

							if (res.data.pageNo == res.data.pages) {
								that.LoadingComplete=true
							}
							var list = res.data.data || []; // 没有数据不操作

							if (list.length == 0 && res.data.pageNo == 1) {
								that.siteItemData.list=[]
								uni.hideLoading();
						that.loading=true
								return false;
							}
							if (type === 'replace') {
								that.siteItemData.list= list
							} else {
								that.siteItemData.list= that.siteItemData.list.concat(list)
							}
							uni.hideLoading();
						that.loading=true
						}
					});
			},

			myevent(e, _dataset) {
				/* ---处理dataset begin--- */
				this.datasetHandle(e, _dataset);
				/* ---处理dataset end--- */
				console.log('占位：函数 myevent 未声明');
			}
		}
	};
</script>
<style lang="less">
    @import "../../../commin/commin.less";

    page{
        background-color: @text-color6;
    }
    .noList {
        text-align: center;
        font-size: 24rpx;
        color: #9699A6;
        padding: 24rpx;
    }
</style>
